@use "lib/viewport";

// --------------------------------------------------
// Topic lists
// --------------------------------------------------

// Base list
// --------------------------------------------------
.topic-list-icons {
  .d-icon-thumbtack {
    color: var(--primary-med-or-secondary-med);
  }

  .d-icon-thumbtack.unpinned {
    color: var(--primary-med-or-secondary-med);
  }

  a.title {
    color: var(--primary);
  }

  .d-icon-bookmark {
    color: var(--primary-med-or-secondary-med);
  }
}

.topic-list {
  @extend .topic-list-icons;
  margin: var(--d-topic-list-margin-y) var(--d-topic-list-margin-x)
    var(--d-topic-list-margin-bottom);

  .topic-list-header {
    font-size: var(--d-topic-list-header-font-size);
  }

  .topic-list-header .topic-list-data {
    padding: var(--d-topic-list-header-data-padding-y)
      var(--d-topic-list-header-data-padding-x);
    color: var(--d-topic-list-header-text-color);
  }

  .topic-list-data {
    padding: var(--d-topic-list-data-padding-y)
      var(--d-topic-list-data-padding-x);

    &:first-of-type {
      padding-inline-start: var(--d-topic-list-data-padding-inline-start);
    }

    &:last-of-type {
      padding-inline-end: var(--d-topic-list-data-padding-inline-end);
    }

    th & {
      border-bottom: 3px solid var(--primary-low);
    }
  }

  button.bulk-select {
    padding: 0;
    border: 0;
    margin-right: var(--space-2);
    line-height: var(--line-height-large);
  }

  .topic-list-data.bulk-select {
    padding: 0;
    width: 30px;

    label {
      margin: 0;
      padding: var(--space-3) var(--space-2);
      cursor: pointer;
    }

    + .main-link {
      padding-left: 0;
    }
  }

  .topics-replies-toggle {
    background: none;
    border: none;
    line-height: var(--line-height-large);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    position: relative;

    &.active {
      @include nav-active;
    }
  }

  $td-posters-height: 29px; // min-height of td with avatar glow
  $td-posters-more-lh: $td-posters-height - 4;

  .posters {
    // we know there are up to 5 avatars of fixed size
    // will be overridden by media width queries on narrow displays to 1 avatar's width
    width: 146px;

    img.avatar {
      height: var(--d-topic-list-avatar-size);
      width: var(--d-topic-list-avatar-size);
    }

    > a {
      float: left;
      margin-right: 4px;

      &:last-of-type {
        margin-right: 0;
      }

      &.posters-more-count {
        cursor: default;
        color: var(--primary-med-or-secondary-med);
        line-height: $td-posters-more-lh;
        font-size: var(--font-down-1);
      }
    }
  }

  td.topic-list-data.posters {
    height: $td-posters-height;
  }

  .posters a:first-child .avatar.latest:not(.single) {
    box-shadow: 0 0 3px 1px rgb(var(--tertiary-rgb), 0.35);
    border: 1px solid rgb(var(--tertiary-rgb), 0.5);
    position: relative;
    left: -2px;
  }

  .likes {
    width: var(--d-topic-list-likes-views-posts-width);
  }

  .views {
    width: var(--d-topic-list-likes-views-posts-width);
  }

  .posts {
    width: var(--d-topic-list-likes-views-posts-width);
  }

  .post-actions {
    clear: both;
    width: auto;
    color: var(--primary-med-or-secondary-med);
    text-align: left;
    font-size: var(--font-down-1);
    margin-top: 5px;

    .fa {
      margin-right: 2px;
    }

    a {
      color: var(--primary-med-or-secondary-med);
      margin-right: 3px;
      line-height: var(--line-height-large);
    }
  }

  .activity {
    width: 4em;

    &:lang(zh_CN) {
      width: 5.3em;
    }
  }

  .age {
    width: 4em;
  }

  .with-year {
    white-space: nowrap;
  }
}

.topic-list-bottom {
  margin: var(--space-5) 0;

  .dismiss-container-bottom {
    float: right;
  }
}

// Misc. stuff
// --------------------------------------------------
#list-area .top-lists {
  h2 {
    cursor: pointer;
    margin: 5px 0 10px;
  }

  .period-chooser .select-kit-body {
    width: 275px;
  }
}

#list-area {
  h2 {
    margin: var(--space-5) 0 var(--space-3);
  }

  .show-more {
    width: 100%;
    z-index: z("base");
    position: absolute;
    top: 0;

    .alert {
      margin: 0;
      padding: var(--space-4) var(--space-8) var(--space-4) var(--space-3);
      gap: var(--space-3);
      align-items: center;

      &.loading {
        color: var(--primary-medium);
        cursor: default;
      }
    }
  }
}

.bulk-select-topics {
  display: inline-flex;
  margin-left: -5px;

  .btn {
    margin-right: var(--space-2);
  }
}

.dismiss-container-top {
  display: flex;
  justify-content: flex-end;
}

.category-breadcrumb {
  // only target the top-level li, not dropdowns
  .select-kit {
    align-self: stretch;
    height: 100%;
  }
}

/* Tablet (portrait) ----------- */

// These styles kick in a little earlier when the sidebar appears

/* stylelint-disable-next-line discourse/no-breakpoint-mixin */
@include breakpoint(medium, $sidebar: true) {
  .topic-list {
    // suppress views column
    .views {
      display: none;
    }

    // reduce width for more title space
    .posts {
      width: 3em;
    }

    .posters {
      width: 2em;
      text-align: center;
    }

    // show only the first poster
    .topic-list-data.posters {
      a:first-child .avatar.latest:not(.single) {
        top: 0;
        left: 0;
      }

      a:not(.latest) {
        display: none;
      }

      a.latest {
        width: 100%;

        img {
          margin: 0 auto;
        }
      }
    }
  }
}

@include viewport.until(lg) {
  .nav-pills {
    > li > a {
      font-size: var(--font-0);
      padding: var(--space-2) var(--space-3);
    }
  }

  .topic-list {
    .topic-list-data {
      font-size: var(--font-0);
    }
  }

  .topic-list-header {
    font-size: var(--font-down-1);
  }
}

.container.list-container {
  position: relative;
  padding: 0 var(--list-container-padding-x);
}

.container.list-container.--categories {
  padding: 0 var(--list-container-categories-padding-x);
}

.container.list-container.--topic-list {
  padding: 0 var(--list-container-topiclist-padding-x);
}
